package com.yowasa.xiuxian.engine.battle.strategy.drop.water;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.engine.battle.strategy.CalAbility;
import com.yowasa.xiuxian.engine.battle.strategy.InherentStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.InherentTiming;
import com.yowasa.xiuxian.exception.HandlerException;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@BS(name="织诗成锦")
@Order(5)
@Component
public class ZhiShiChengJing extends BaseSpellStrategy {
    @Override
    public ElementEnum getElement() {
        return ElementEnum.WATER;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int costMp = first.getBattleInfo().getMp() / 10;
        first.getBattleInfo().setCmp(first.getBattleInfo().getCmp() - costMp);

        BuffContent buffContent = new BuffContent();
        buffContent.setDuration(20);
        buffContent.setNum(3);
        first.getBuff().put("雨帘剑", buffContent);
        content.getMsgLog().add(first.getUserBO().getName() + "消耗" + costMp + "点蓝量,召唤了三把雨帘剑环绕周身");
        first.getCd().put("织诗成锦", 5);

    }

    @Override
    public void limit(UserBO user) {
        if (user.getElement().get("水") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY) {
            throw new HandlerException("学习/使用织诗成锦必须具有水灵根");
        }
    }

    @Override
    public String limitDesc() {
        return "具有水灵根";
    }


    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        Integer cd = user.getCd().get("织诗成锦");
        if (cd != null && cd > 0) {
            return false;
        }
        int costMp = user.getBattleInfo().getMp() / 10;
        return user.getBattleInfo().getCmp() >= costMp;
    }

    @Override
    public String desc() {
        return "消耗10%mp，唤出三把雨帘剑，当你进攻时，会消耗一把雨帘剑回复5%的血量，cd 5回合";
    }


}
